﻿using System.Collections.Generic;
using JetBrains.ReSharper.Psi.CSharp.Tree;
using Twins.Infrastructure;
using Twins.Interface;
using Twins.Interface.IHandler;

namespace Twins.Classes.Hanlder.HanlderStatement
{
    public class HanlderForIForeachStatement : IHandler<IForeachStatement>
    {
        public IEnumerable<ILineCode> DoFor(IForeachStatement foreachStatement)
        {
            var receiveHashLineCodeFromProcesserCSharpStatement = IoC
                .Resolve<IReceiveHashLineCodeFromProcesserCSharpStatement>();
            return receiveHashLineCodeFromProcesserCSharpStatement
                .ReceiveHashLineCode(foreachStatement,foreachStatement.Body, foreachStatement.ForeachKeyword.GetText()); 
        }

        public IEnumerable<ILineCode> DoFor(object obj)
        {
            return DoFor((IForeachStatement)obj);
        }
    }
}
